//
//  ReqActivity.swift
//  jiahui
//
//  Created by 3tee on 2024/11/26.
//

import Foundation
import Moya
import MBProgressHUD

struct  ReqActivity: PluginType {
    let showHud :Bool
    func willSend(_ request: any RequestType, target: any TargetType) {
        if showHud {
            DispatchQueue.main.async {
                MBProgressHUD.showAdded(to: UIApplication.shared.keyWindow!, animated: true)
            }
        }
    }
    func didReceive(_ result: Result<Response, MoyaError>, target: any TargetType) {
        if showHud {
            DispatchQueue.main.async {
                MBProgressHUD.hide(for: UIApplication.shared.keyWindow!, animated: true)
            }
        }
    }
}
